<?php
/**
 * Created by PhpStorm.
 * User: sunshubo
 * Date: 2017/9/15
 * Time: 17:02
 */

class UserAdd extends CI_Model
{
    /**
     *
     */
    function add_user($data)
    {
//        var_dump($task[name]);
        $name = $data['name'];
        $sex = $data['sex'];
        $grade = $data['grade'];
        $school = $data['school'];
        $class = $data['class'];
        $pos = $data['pos'];
        $exec = $data['exec'];
        $late_mark = $data['late_mark'];

        $sql = /** @lang text */
            "INSERT INTO ws_baseinfo(name,sex,school,grade,class,pos,late_mark,exec) VALUES('$name',$sex,$school,$grade,$class,$pos,'$late_mark',$exec)";

//        $this->db->trans_start();
        $query = $this->db->query($sql);
//        $this->db->trans_complete();
        $error = $this->db->error();
        if ($query) {
            return json_encode(array('result' => SUCCESS, 'msg' => $this->config->item('mysql_msg')[$error['code']]));
        }
        return json_encode(array('result' => ERROR, 'msg' => $this->config->item('mysql_msg')[$error['code']], 'code' => $error['code']));
    }
}